/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * StudentForm.java
 *
 * Created on 30-03-2012, 21:45:29
 */
package Management;

import ConnectData.Config;
import ConnectData.getConnections;
import Register.MyMD5;
import UploadData.Database;
import UploadData.Student;
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author s0lo
 */
public class StudentForm extends javax.swing.JFrame {
    private static int StuID;
    private static String user;
    private static String pw;
    private String oldPassword;
    private String newPassword;
    private String reNewPassword;
    private static String Access;
     private String fullName;
    private String phone;
    private String email;
    private String Address;
    private String Gender;

    private Vector vtCertificate;
    private Vector vttem2;
    private Vector vttem3;
    private Vector vtStudent1;
    private Vector vtCourseRegister;

    /** Creates new form StudentForm */
    public StudentForm(String User, String pass, String Access) {
        initComponents();
        this.user = User;
        this.pw = pass;
        this.Access = Access;
        vtStudent1 = new Database().loadStudent(" where UserName='" + user +"'");
        Vector vtStudent = (Vector) vtStudent1.get(0);
        this.StuID = Integer.parseInt( vtStudent.get(0).toString());
        initData();
    }
    public void initData() {
        vtStudent1 = new Database().loadStudent(" where StuID=" + StuID);
        Vector vtStudent = (Vector) vtStudent1.get(0);
        txtFullName.setText(vtStudent.get(4).toString());
        Date birthday = (Date) (vtStudent.get(5));
        jdcBirthDate.setDate(birthday);
        String Gender = vtStudent.get(6).toString();
        if (Gender.trim().equals("0")) {
            chkFeMale.setSelected(true);
        } else if (Gender.equals("1")) {
            chkMale.setSelected(true);
        }
        txtPhone.setText(vtStudent.get(7).toString());
        txtEmail.setText(vtStudent.get(8).toString());
        txtAdd.setText(vtStudent.get(9).toString());
        String Status = vtStudent.get(3).toString();
        if (Status.trim().equals("0")) {
            chkDeny.setSelected(true);
        } else if (Status.equals("1")) {
            chkAllow.setSelected(true);
        }
        initCourseRegister();
        initCertificate();
    }
     public void initCourseRegister() {
        Vector vtCol;
        vtCol = new Vector();
        String headline;
        headline = "Course Name";
        vtCol.add(headline);
        headline = "Start Date";
        vtCol.add(headline);
        headline = "End Date";
        vtCol.add(headline);
        headline = "Status";
        vtCol.add(headline);
        vtCourseRegister = new Database().loadCourseRegister(" where StuID=" + StuID);
        Vector vttem = new Vector();
        vttem2 = new Vector();
        for (int i = 0; i < vtCourseRegister.size(); i++) {

            String CourseName = "";
            int CourID = Integer.parseInt(((Vector) vtCourseRegister.get(i)).get(2).toString());
            Vector vtCour = new Database().loadCourse(" where CourseID='" + CourID + "'");
            if (vtCour.size() > 0) {
                int courID;
                for (int j = 0; j < vtCour.size(); j++) {
                    courID = Integer.parseInt(((Vector) vtCour.get(j)).get(0).toString());
                    if (courID == CourID) {
                        CourseName = ((Vector) vtCour.get(j)).get(1).toString();
                    }
                }
            }
            vttem.add(CourseName);
            vttem.add(((Vector) vtCourseRegister.get(i)).get(3));
            vttem.add(((Vector) vtCourseRegister.get(i)).get(4));
            int Status = Integer.parseInt(((Vector) vtCourseRegister.get(i)).get(5).toString());
            if (Status == 1) {
                vttem.add("Successful");
            } else {
                vttem.add("Unsuccessful");
            }
            vttem2.add(vttem);
            vttem = new Vector();
        }
        DefaultTableModel dtm = new DefaultTableModel(vttem2, vtCol);
        tbInfoCourseRegister.setModel(dtm);
    }
    public void initCertificate() {
        Vector vtCol;
        vtCol = new Vector();
        String headline;
        headline = "Course Name";
        vtCol.add(headline);
        headline = "Start Date";
        vtCol.add(headline);
        headline = "End Date";
        vtCol.add(headline);
        headline = " Rate ";
        vtCol.add(headline);
        headline = "Degree Day";
        vtCol.add(headline);

          
        vtCertificate = new Database().loadvwCetificate(" where StuID=" + StuID);
        Vector vttem = new Vector();
        vttem3 = new Vector();
        for (int i = 0; i < vtCertificate.size(); i++) {
            vttem.add(((Vector) vtCertificate.get(i)).get(4));
            vttem.add(((Vector) vtCertificate.get(i)).get(5));
            vttem.add(((Vector) vtCertificate.get(i)).get(6));
            float Mark = Float.parseFloat(((Vector) vtCertificate.get(i)).get(7).toString());

            if (Mark >= 7.5) {
                vttem.add("Distinction");
            } else if (Mark >= 6 && Mark < 7.5) {
                vttem.add("A");
            } else if (Mark >= 5 && Mark < 6) {
                vttem.add("B");
            } else if (Mark >= 4 && Mark < 5) {
                vttem.add("C");
            }
            vttem.add(((Vector) vtCertificate.get(i)).get(8));
            vttem3.add(vttem);
            vttem = new Vector();
        }
        DefaultTableModel dtm = new DefaultTableModel(vttem3, vtCol);
        tbCertificate.setModel(dtm);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tbInfoCourse = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbCertificate = new javax.swing.JTable();
        btnClose5 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jPanel16 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tbInfoCourseRegister = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        btnClose4 = new javax.swing.JButton();
        panPrivate = new javax.swing.JPanel();
        txtFullName = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtPhone = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtAdd = new javax.swing.JTextField();
        btnUpdatePri = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        chkAllow = new javax.swing.JRadioButton();
        chkDeny = new javax.swing.JRadioButton();
        jdcBirthDate = new com.toedter.calendar.JDateChooser();
        jPanel4 = new javax.swing.JPanel();
        chkMale = new javax.swing.JRadioButton();
        chkFeMale = new javax.swing.JRadioButton();
        btnClose3 = new javax.swing.JButton();
        jPanel14 = new javax.swing.JPanel();
        txtOldPass = new javax.swing.JPasswordField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        txtNewPass = new javax.swing.JPasswordField();
        txtRePass = new javax.swing.JPasswordField();
        jLabel19 = new javax.swing.JLabel();
        btnChange1 = new javax.swing.JToggleButton();
        btnClose2 = new javax.swing.JButton();
        lbUserName = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(153, 255, 204));
        jPanel1.setAutoscrolls(true);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/90.6peopleonworld.jpg"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 190, Short.MAX_VALUE)
        );

        jTabbedPane1.setBackground(new java.awt.Color(0, 255, 204));
        jTabbedPane1.setAutoscrolls(true);
        jTabbedPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTabbedPane1.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                jTabbedPane1AncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        jPanel8.setBackground(new java.awt.Color(204, 255, 204));

        tbInfoCourse.setForeground(new java.awt.Color(0, 0, 51));
        tbInfoCourse.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane5.setViewportView(tbInfoCourse);

        tbCertificate.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tbCertificate.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbCertificateMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tbCertificate);

        btnClose5.setFont(new java.awt.Font("Arial", 1, 12));
        btnClose5.setForeground(new java.awt.Color(0, 0, 51));
        btnClose5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/close1.png"))); // NOI18N
        btnClose5.setText("Close");
        btnClose5.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnClose5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClose5ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jButton2.setForeground(new java.awt.Color(0, 0, 51));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/info.png"))); // NOI18N
        jButton2.setText("Detail");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 679, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnClose5, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                            .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 421, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(38, 38, 38))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnClose5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(64, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("  Certificate   ", new javax.swing.ImageIcon(getClass().getResource("/icon/Course.jpg")), jPanel8); // NOI18N

        jPanel7.setBackground(new java.awt.Color(204, 255, 204));

        jPanel16.setBackground(new java.awt.Color(204, 255, 204));

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        tbInfoCourseRegister.setForeground(new java.awt.Color(0, 0, 51));
        tbInfoCourseRegister.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane6.setViewportView(tbInfoCourseRegister);

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jButton1.setForeground(new java.awt.Color(0, 0, 51));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/info.png"))); // NOI18N
        jButton1.setText("Detail");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        btnClose4.setFont(new java.awt.Font("Arial", 1, 12));
        btnClose4.setForeground(new java.awt.Color(0, 0, 51));
        btnClose4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/close1.png"))); // NOI18N
        btnClose4.setText("Close");
        btnClose4.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnClose4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClose4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 576, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnClose4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 59, Short.MAX_VALUE)
                .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(31, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(97, 97, 97)
                        .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(24, 24, 24)
                                .addComponent(btnClose4, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 347, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(89, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Payment", new javax.swing.ImageIcon(getClass().getResource("/icon/payment.png")), jPanel7); // NOI18N

        panPrivate.setBackground(new java.awt.Color(204, 255, 204));

        txtFullName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFullNameActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setForeground(new java.awt.Color(0, 0, 51));
        jLabel1.setText("Full Name:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setForeground(new java.awt.Color(0, 0, 51));
        jLabel3.setText("Date of Birth:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel7.setForeground(new java.awt.Color(0, 0, 51));
        jLabel7.setText("Address :");

        txtPhone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPhoneActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel5.setForeground(new java.awt.Color(0, 0, 51));
        jLabel5.setText("Phone:");

        txtEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtEmailActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel6.setForeground(new java.awt.Color(0, 0, 51));
        jLabel6.setText("Email:");

        txtAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtAddActionPerformed(evt);
            }
        });

        btnUpdatePri.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnUpdatePri.setForeground(new java.awt.Color(0, 0, 51));
        btnUpdatePri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/save.png"))); // NOI18N
        btnUpdatePri.setText("Update");
        btnUpdatePri.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdatePrionUpdatePrivateInfo(evt);
            }
        });

        jPanel2.setBackground(new java.awt.Color(204, 255, 204));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N
        jPanel2.setForeground(new java.awt.Color(0, 0, 51));

        chkAllow.setBackground(new java.awt.Color(204, 255, 204));
        chkAllow.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkAllow.setForeground(new java.awt.Color(0, 0, 51));
        chkAllow.setText("Allow");

        chkDeny.setBackground(new java.awt.Color(204, 255, 204));
        chkDeny.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkDeny.setForeground(new java.awt.Color(0, 0, 51));
        chkDeny.setText("Deny");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(62, Short.MAX_VALUE)
                .addComponent(chkAllow)
                .addGap(49, 49, 49)
                .addComponent(chkDeny)
                .addGap(79, 79, 79))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkAllow)
                .addComponent(chkDeny))
        );

        jPanel4.setBackground(new java.awt.Color(204, 255, 204));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Gender", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N
        jPanel4.setForeground(new java.awt.Color(0, 0, 51));

        chkMale.setBackground(new java.awt.Color(204, 255, 204));
        chkMale.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkMale.setForeground(new java.awt.Color(0, 0, 51));
        chkMale.setText("Male");

        chkFeMale.setBackground(new java.awt.Color(204, 255, 204));
        chkFeMale.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkFeMale.setForeground(new java.awt.Color(0, 0, 51));
        chkFeMale.setText("FeMale");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(62, Short.MAX_VALUE)
                .addComponent(chkMale)
                .addGap(49, 49, 49)
                .addComponent(chkFeMale)
                .addGap(79, 79, 79))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkMale)
                .addComponent(chkFeMale))
        );

        btnClose3.setFont(new java.awt.Font("Arial", 1, 12));
        btnClose3.setForeground(new java.awt.Color(0, 0, 51));
        btnClose3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/close1.png"))); // NOI18N
        btnClose3.setText("Close");
        btnClose3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnClose3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClose3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panPrivateLayout = new javax.swing.GroupLayout(panPrivate);
        panPrivate.setLayout(panPrivateLayout);
        panPrivateLayout.setHorizontalGroup(
            panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panPrivateLayout.createSequentialGroup()
                .addGap(96, 96, 96)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(panPrivateLayout.createSequentialGroup()
                            .addComponent(jLabel7)
                            .addGap(31, 31, 31)
                            .addComponent(txtAdd))
                        .addGroup(panPrivateLayout.createSequentialGroup()
                            .addGap(83, 83, 83)
                            .addComponent(btnUpdatePri)
                            .addGap(26, 26, 26)
                            .addComponent(btnClose3, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(panPrivateLayout.createSequentialGroup()
                            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel5)
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel1))
                            .addGap(6, 6, 6)
                            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtPhone)
                                .addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)
                                .addComponent(txtFullName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                                .addComponent(jdcBirthDate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                .addGap(794, 794, 794))
            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panPrivateLayout.createSequentialGroup()
                    .addGap(106, 106, 106)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(804, Short.MAX_VALUE)))
        );
        panPrivateLayout.setVerticalGroup(
            panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panPrivateLayout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFullName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jdcBirthDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(106, 106, 106)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnUpdatePri, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnClose3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28))
            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panPrivateLayout.createSequentialGroup()
                    .addContainerGap(185, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(212, 212, 212)))
        );

        jTabbedPane1.addTab("Private Informations", new javax.swing.ImageIcon(getClass().getResource("/icon/info.png")), panPrivate); // NOI18N

        jPanel14.setBackground(new java.awt.Color(204, 255, 204));
        jPanel14.setForeground(new java.awt.Color(0, 0, 51));

        txtOldPass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtOldPassActionPerformed(evt);
            }
        });

        jLabel17.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel17.setForeground(new java.awt.Color(0, 0, 51));
        jLabel17.setText("Old PassWord :");

        jLabel18.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel18.setForeground(new java.awt.Color(0, 0, 51));
        jLabel18.setText("New PassWord :");

        txtNewPass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNewPassActionPerformed(evt);
            }
        });

        txtRePass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtRePassActionPerformed(evt);
            }
        });

        jLabel19.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel19.setForeground(new java.awt.Color(0, 0, 51));
        jLabel19.setText("Re-PassWord :");

        btnChange1.setFont(new java.awt.Font("Arial", 1, 12));
        btnChange1.setForeground(new java.awt.Color(0, 0, 51));
        btnChange1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/save.png"))); // NOI18N
        btnChange1.setText("Save");
        btnChange1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChange1ActionPerformed(evt);
            }
        });

        btnClose2.setFont(new java.awt.Font("Arial", 1, 12));
        btnClose2.setForeground(new java.awt.Color(0, 0, 51));
        btnClose2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/close1.png"))); // NOI18N
        btnClose2.setText("Close");
        btnClose2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnClose2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClose2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGap(288, 288, 288)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel17)
                            .addComponent(jLabel19))
                        .addGap(23, 23, 23))
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jLabel18)
                        .addGap(18, 18, 18)))
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtOldPass, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNewPass, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtRePass, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(btnChange1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnClose2, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(319, Short.MAX_VALUE))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGap(64, 64, 64)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(txtOldPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtNewPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(txtRePass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnChange1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnClose2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(252, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Change Password", new javax.swing.ImageIcon(getClass().getResource("/icon/pass.png")), jPanel14); // NOI18N

        lbUserName.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbUserName.setForeground(new java.awt.Color(0, 0, 51));
        lbUserName.setText("   ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(444, 444, 444)
                .addComponent(lbUserName)
                .addContainerGap(499, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 930, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(lbUserName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 928, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnChange1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChange1ActionPerformed
        // TODO add your handling code here:
        if (validateInformation()) {
            Connection cn = null;
            PreparedStatement pst = null;
            ResultSet rs = null;
            try {
                cn = new Config().cn;
                pst = cn.prepareStatement("select * from Students where UserName=?");
                pst.setString(1, user);
                rs = pst.executeQuery();
                while (rs.next()) {
                    String pwmd = MyMD5.getMD5String(txtOldPass.getText());
                    if (!rs.getString("StuPassword").equals(pwmd)) {
                        JOptionPane.showMessageDialog(this, "Your old password do not correct");
                        txtOldPass.setText("");
                        txtOldPass.requestFocus();
                    } else {
                        cn = new Config().cn;
                        String strUpdate = "update Students set StuPassword=? where UserName=?";
                        pst = cn.prepareStatement(strUpdate);
                        pst.setString(1, MyMD5.getMD5String(txtNewPass.getText().trim()));
                        pst.setString(2, user);
                        pst.executeUpdate();
                        JOptionPane.showMessageDialog(this, "Change Password Successfully");
                        txtOldPass.setText("");
                        txtNewPass.setText("");
                        txtRePass.setText("");
                    }
                }
            } catch (SQLException se) {
            } catch (HeadlessException he) {
            } catch (Exception e) {
            } finally {
                getConnections.closeObject(rs);
                getConnections.closeObject(pst);
                getConnections.closeObject(cn);
            }
        }
    }//GEN-LAST:event_btnChange1ActionPerformed

    private void btnClose2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClose2ActionPerformed
        // TODO add your handling code here:
        int i = JOptionPane.showConfirmDialog(this, "Are you sure you want to exit! ", "Exit", 2);
        if (i == 0) {
            this.dispose();
        }
}//GEN-LAST:event_btnClose2ActionPerformed

    private void jTabbedPane1AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jTabbedPane1AncestorAdded
        // TODO add your handling code here:
}//GEN-LAST:event_jTabbedPane1AncestorAdded

    private void tbCertificateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbCertificateMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_tbCertificateMouseClicked

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        int rscurrent = tbInfoCourseRegister.getSelectedRow();
        if (rscurrent >= 0) {
            int CRID = Integer.parseInt(((Vector) vtCourseRegister.get(rscurrent)).get(0).toString());
            int CourID = Integer.parseInt(((Vector) vtCourseRegister.get(rscurrent)).get(2).toString());
            new CourseDetail(CRID, StuID, CourID,"0");

        } else {
            JOptionPane.showMessageDialog(this, "Please Select Course do you want Watch Detail!");
        }
}//GEN-LAST:event_jButton1ActionPerformed

    private void btnUpdatePrionUpdatePrivateInfo(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdatePrionUpdatePrivateInfo
        // TODO add your handling code here:
        boolean valid = validateInformationStudent();
        if (valid) {
            boolean Gender;
            if (chkMale.isSelected()) {
                Gender = false;
            } else {
                Gender = true;
            }
            int Status;
            if (chkAllow.isSelected()) {
                Status = 1;
            } else {
                Status = 0;
            }
            Student stu = new Student();
            stu.setStatus(Status);
            stu.setStuName(txtFullName.getText());
            Date birthday = jdcBirthDate.getDate();
            SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy");
            stu.setStuBirthDay(SDF.format(birthday));
            stu.setStuGender(Gender);
            stu.setStuPhone(txtPhone.getText());
            stu.setStuEmail(txtEmail.getText());
            stu.setStuAddress(txtAdd.getText());
            stu.setStuID(StuID);


            int k = new Database().UpdateStudent(stu);


            if (k != -1) {
                JOptionPane.showMessageDialog(this, "Update successful!");
            }

        }
}//GEN-LAST:event_btnUpdatePrionUpdatePrivateInfo

    private void btnClose3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClose3ActionPerformed
        // TODO add your handling code here:
         int i = JOptionPane.showConfirmDialog(this, "Are you sure you want to exit! ", "Exit", 2);
        if (i == 0) {
            this.dispose();
        }
    }//GEN-LAST:event_btnClose3ActionPerformed

    private void btnClose4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClose4ActionPerformed
        // TODO add your handling code here:
         int i = JOptionPane.showConfirmDialog(this, "Are you sure you want to exit! ", "Exit", 2);
        if (i == 0) {
            this.dispose();
        }
    }//GEN-LAST:event_btnClose4ActionPerformed

    private void btnClose5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClose5ActionPerformed
        // TODO add your handling code here:
         int i = JOptionPane.showConfirmDialog(this, "Are you sure you want to exit! ", "Exit", 2);
        if (i == 0) {
            this.dispose();
        }
    }//GEN-LAST:event_btnClose5ActionPerformed

    private void txtFullNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFullNameActionPerformed
        // TODO add your handling code here:
        btnUpdatePrionUpdatePrivateInfo(evt);
        jdcBirthDate.requestFocus();
    }//GEN-LAST:event_txtFullNameActionPerformed

    private void txtPhoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPhoneActionPerformed
        // TODO add your handling code here:
         btnUpdatePrionUpdatePrivateInfo(evt);
        txtEmail.requestFocus();
    }//GEN-LAST:event_txtPhoneActionPerformed

    private void txtEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtEmailActionPerformed
        // TODO add your handling code here:
         btnUpdatePrionUpdatePrivateInfo(evt);
        txtAdd.requestFocus();
    }//GEN-LAST:event_txtEmailActionPerformed

    private void txtAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtAddActionPerformed
        // TODO add your handling code here:
         btnUpdatePrionUpdatePrivateInfo(evt);
    }//GEN-LAST:event_txtAddActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
         int rscurrent = tbCertificate.getSelectedRow();
        if (rscurrent >= 0) {
            int CRID = Integer.parseInt(((Vector) vtCertificate.get(rscurrent)).get(1).toString());
            int CourID = Integer.parseInt(((Vector) vtCertificate.get(rscurrent)).get(3).toString());
            new CourseDetail(CRID, StuID, CourID,"0");

        } else {
            JOptionPane.showMessageDialog(this, "Please Select Course do you want Watch Detail!");
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void txtOldPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtOldPassActionPerformed
        // TODO add your handling code here:
        btnChange1ActionPerformed(evt);
    }//GEN-LAST:event_txtOldPassActionPerformed

    private void txtNewPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNewPassActionPerformed
        // TODO add your handling code here:
        btnChange1ActionPerformed(evt);
    }//GEN-LAST:event_txtNewPassActionPerformed

    private void txtRePassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtRePassActionPerformed
        // TODO add your handling code here:
        btnChange1ActionPerformed(evt);
    }//GEN-LAST:event_txtRePassActionPerformed

     public boolean validateInformation() {
        oldPassword = txtOldPass.getText();
        if (oldPassword.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your old password!");
            txtOldPass.requestFocus();
            return false;
        }
        newPassword = txtNewPass.getText();
        if (newPassword.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your new password!");
            txtNewPass.requestFocus();
            return false;
        }
        if (newPassword.length() < 6) {
            JOptionPane.showMessageDialog(this, "Password >6 character!");
            txtNewPass.requestFocus();
            return false;
        }
        reNewPassword = txtRePass.getText();
        if (reNewPassword.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your confirm new passWord!");
            txtRePass.requestFocus();
            return false;
        }
        if (!newPassword.equals(reNewPassword)) {
            JOptionPane.showMessageDialog(this, "Your password do not match ");
            txtRePass.setText("");
            txtRePass.requestFocus();
            return false;
        }
        return true;
    }
      public boolean validateInformationStudent() {
        fullName = txtFullName.getText();
        if (fullName.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your Student name!");
            txtFullName.requestFocus();
            return false;
        }
        phone = txtPhone.getText();
        if (phone.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your Phone!");
            txtPhone.requestFocus();
            return false;
        } else {
            String phoneRegex = "[0-9]+";
            Pattern p = Pattern.compile(phoneRegex);
            Matcher m = p.matcher(phone);
            if (!m.matches()) {
                JOptionPane.showMessageDialog(this, "Phone is incorrect!");
                txtPhone.requestFocus();
                txtPhone.selectAll();
                return false;
            }
        }
        Date Birthday = jdcBirthDate.getDate();
        if (Birthday == null) {
            JOptionPane.showMessageDialog(this, "Birthday must not empty!", "Notify Message", JOptionPane.INFORMATION_MESSAGE);
            jdcBirthDate.requestFocus();
            return false;
        }
        Date d = new Date();
        if (Birthday != null) {
            if (jdcBirthDate.getCalendar().getTime().after(d)) {
                JOptionPane.showMessageDialog(this, "Birthday must be less than today!", "Notify Message", JOptionPane.INFORMATION_MESSAGE);
                jdcBirthDate.setDate(null);
                jdcBirthDate.requestFocus();
                return false;
            }
        }
        email = txtEmail.getText().trim();
        if (email.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your email");
            txtEmail.requestFocus();
            return false;
        } else {
            String emailRegex = "[a-zA-Z_]+[a-zA-Z0-9_]*@([a-zA-Z]+\\.)+[a-zA-Z]+";
            Pattern p = Pattern.compile(emailRegex);
            Matcher m = p.matcher(email);
            if (!m.matches()) {
                JOptionPane.showMessageDialog(this, "Email is incorrect!");
                txtEmail.requestFocus();
                txtEmail.selectAll();
                return false;
            }
        }
        Address = txtAdd.getText();
        if (Address.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your Student Address!");
            txtAdd.requestFocus();
            return false;
        }
        return true;
    }
    /**
     * @param args the command line arguments
     */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton btnChange1;
    private javax.swing.JButton btnClose2;
    private javax.swing.JButton btnClose3;
    private javax.swing.JButton btnClose4;
    private javax.swing.JButton btnClose5;
    private javax.swing.JButton btnUpdatePri;
    private javax.swing.JRadioButton chkAllow;
    private javax.swing.JRadioButton chkDeny;
    private javax.swing.JRadioButton chkFeMale;
    private javax.swing.JRadioButton chkMale;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private com.toedter.calendar.JDateChooser jdcBirthDate;
    private javax.swing.JLabel lbUserName;
    private javax.swing.JPanel panPrivate;
    private javax.swing.JTable tbCertificate;
    private javax.swing.JTable tbInfoCourse;
    private javax.swing.JTable tbInfoCourseRegister;
    private javax.swing.JTextField txtAdd;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtFullName;
    private javax.swing.JPasswordField txtNewPass;
    private javax.swing.JPasswordField txtOldPass;
    private javax.swing.JTextField txtPhone;
    private javax.swing.JPasswordField txtRePass;
    // End of variables declaration//GEN-END:variables
}
